Skip to content

Add a future incompat warning for #[no_link] - #164028

Open
bjorn3 wants to merge 1 commit into
rust-lang:mainfrom
bjorn3:no_link_fcw
Open

bjorn3 wants to merge 1 commit into
rust-lang:mainfrom
bjorn3:no_link_fcw

Conversation

@bjorn3

@bjorn3 bjorn3 commented Oct 9, 2026

Copy link
Copy Markdown
Member

This is a pre-1.0 attribute that accidentally got stabilized. It was only meant for compiler plugins which we no longer support, not for regular crates. It is rather fragile and can easily lead to linker errors depending on where rustc decides to codegen functions and statics, which varies between rustc versions. It might also be unsound if a crate for example expects a global constructor it defined to run. Using it doesn't have an effect on the size of the produced binaries except when it defines a #[used] static given that we remove all unused functions and statics at link time already.

@rustbot

rustbot commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 9, 2026
@rustbot

rustbot commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

r? @mu001999

rustbot has assigned @mu001999.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 20 candidates

@bjorn3

bjorn3 commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

This was previously cratered in #152856 (comment). That PR entirely removed #[no_link], while this one only emits a future incompat lint.

@JonathanBrouwer JonathanBrouwer added T-lang Relevant to the language team I-lang-nominated Nominated for discussion during a lang team meeting. S-waiting-on-t-lang Status: Awaiting decision from T-lang and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 9, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

Given that the crater run only found 6 crates that this broke, I also wouldn't be against entirely removing the attribute immediately. What we want to do here is a @rust-lang/lang decision though, so lets let them decide

@rust-log-analyzer

This comment has been minimized.

@bjorn3

bjorn3 commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

I think it is polite to keep it as future incompat warning for a couple of releases.

@bjorn3

bjorn3 commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

Blessed the tests and added #164032 as tracking issue.

@rust-log-analyzer

This comment has been minimized.

@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Oct 10, 2026
Comment thread compiler/rustc_lint_defs/src/builtin.rs Outdated
Comment thread compiler/rustc_lint_defs/src/builtin.rs Outdated
@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

This is a pre-1.0 attribute that accidentally got stabilized. It was
only meant for compiler plugins which we no longer support, not for
regular crates. It is rather fragile and can easily lead to linker
errors depending on where rustc decides to codegen functions and
statics, which varies between rustc versions. It might also be unsound
if a crate for example expects a global constructor it defined to run.
Using it doesn't have an effect on the size of the produced binaries
except when it defines a `#[used]` static given that we remove all
unused functions and statics at link time already.
@traviscross

Copy link
Copy Markdown
Contributor

Makes sense to me. Thanks @bjorn3 and @JonathanBrouwer. I propose that we do this.

@rfcbot fcp merge lang

@rust-rfcbot

rust-rfcbot commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

@traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-t-lang Status: Awaiting decision from T-lang T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants